#include "stdafx.h"
#include "DatabaseIndex.h"
using namespace std;


void DatabaseIndex::AddData( CString* index, NeededData* stNeedData )
{
	if( AlreadyHave(*index, &m_Index) )
	{
		m_Index[*index].push_back(stNeedData);
	}
	else
	{
		std::vector<NeededData*> vectemp;
		vectemp.push_back(stNeedData);
		m_Index.insert( make_pair(*index, vectemp));
	}
}

bool DatabaseIndex::AlreadyHave( CString index,const std::map<CString, std::vector<NeededData*>>* m_Index )
{
	const std::map< CString, vector<NeededData*> >::const_iterator it = m_Index->find(index);
	return it != m_Index->end();
}

DatabaseIndex::DatabaseIndex()
{
}

DatabaseIndex::~DatabaseIndex()
{

}

std::map<CString, std::vector<NeededData*>> DatabaseIndex::GetData()
{
	return m_Index;
}

void DatabaseIndex::ClearDataIndex()
{
	m_Index.clear();
}